<!DOCTYPE html>
<html>

<head>
  <script src="../node_modules/angular/angular.js"></script>
  <script src="../node_modules/angular-resource/angular-resource.js"></script>
</head>

<body ng-app="demo">
  <div ng-controller="DemoController">
    <button ng-click="queryResult()">获取</button>
    <button ng-click="saveResult()">保存</button>
    <p>结果：{{ result }}</p>
  </div>
  <script>
    const demo = angular.module('demo', ['ngResource']) // 引入模块
    demo.controller('DemoController', function ($scope, $resource) {
      $scope.result = '...'

      const result = $resource('result', {}, {
        query: {
          url: './result.txt',
          method: 'GET',
          params: { page: 1, size: 10 }
        },
        save: {
          url: 'http://localhost:6678',
          method: 'POST',
        }
      })

      $scope.queryResult = () => {
        result.query(function (res) {
          console.log(res)
        })
      }

      $scope.saveResult = () => {
        // result.save({ result: 123 }, function (res) {
        result.save(, function (res) {
          console.log(res)
        })
      }
    });
  </script>
</body>

</html>